//
//  CacheData.h
//  KidReading
//
//  Created by telen on 14/12/4.
//  Copyright (c) 2014年 刘赞黄Telen. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
typedef enum : NSInteger{
    TiredStyle_None,
    TiredStyle_FifteenMinutes,
    TiredStyle_HalfHour,
    TiredStyle_FortyFiveMinutes,
    TiredStyle_OneHour,
}TiredStyle;

#define __CacheKey__ @"CacheKey"
#define __IsWifiStyle @"isWifiStyle"
#define __VoiceStyle @"vocieStyle"
#define __TiredStyle @"tiredStyle"
#define __TiredStyle_switchOff @"tiredStyle_switchOff"

#define __BookDownOrderArr @"bookDownOrder"
#define __TalkDownOrderArr @"talkDownOrder"
#define __BookDownIng @"bookDownIng"
#define __TalkDownIng @"talkDownIng"
#define __TalkVideoDownIng @"talkVideoDownIng"
#define __BookOpenRecord @"bookOpenRecords"
#define __TalkOpenRecord @"talkOpenRecords"
#define __FlowBookOpenRecrod @"flowBookOpenRecord"

@class UserInfo;

#pragma mark- CacheData
@interface CacheData : NSObject
{
    NSMutableDictionary* netCache;
    NSMutableDictionary* bookCache;
    NSMutableDictionary* talkCache;
    NSMutableDictionary* talkVideoCache;
    UserInfo* userinfo;
}

+(CacheData*) shareSingle;

//常规网络请求缓存
-(void) updateNetCache:(NSDictionary*)dict forKey:(NSString*)key;
-(NSDictionary*) getNetCacheForKey:(NSString*)key;
//
-(NSDictionary*) getNetCacheForBookID:(NSInteger)bookID withHomeCacheKey:(NSString*)homeKey;
-(NSArray*) getNetCaheForGridID:(NSInteger)grid withHomeCacheKey:(NSString *)homeKey;
//
//用户网络请求缓存
-(void) updateNetCache:(NSDictionary*)dict forKey:(NSString*)key forUid:(NSInteger)uid;
-(NSDictionary*) getNetCacheForKey:(NSString*)key forUid:(NSInteger)uid;
//
-(NSDictionary*) getNetCacheForBookID:(NSInteger)bookID withHomeCacheKey:(NSString*)homeKey forUid:(NSInteger)uid;
-(NSArray*) getNetCaheForGridID:(NSInteger)grid withHomeCacheKey:(NSString *)homeKey  forUid:(NSInteger)uid;
//
//书本下载版本信息缓存

-(void) updateBook:(NSInteger)bookid CacheEdition:(long long)edition;
-(void) updateBook:(NSInteger)bookid DownEdition:(long long)edition;
-(void) deleteBookCache:(NSInteger)bookid forUid:(NSInteger)uid;//删除所以数据，和指定id用户记录
-(void) cleanBookCache;
-(long long) getEditionForBook:(NSInteger)bookid;
-(long long) getEditionForDownIngBook:(NSInteger)bookid;
-(NSArray*) getAllDownBooksIDstr;
-(BOOL)isBookDownDoneWithBookId:(NSInteger)bookId;

/**删除一组书*/
-(void)deleteBooksCacheWithBookIds:(NSArray*)bookIds ForUid:(NSInteger)uid;
- (void)saveBookCache;


//talk edition 管理
//get
-(long long) getEditionFordownloadingTalk:(NSInteger)talkid;
//udate
-(void) updateTalk:(NSInteger)talkid DownEdition:(long long)edition;
//delete
-(void)deleteTalkCache:(NSInteger)talkid;

//talkVideo edition 管理
-(long long) getEditionFordownloadingTalkVideo:(NSInteger)videoid;
//udate
-(void) updateTalkVideo:(NSInteger)videoid DownEdition:(long long)edition;
//delete
-(void)deleteTalkVideoCache:(NSInteger)videoid;
//批量删除cache
-(void)deleteTalkVideoCacheByIDArray:(NSArray *)videoidArray;

//用户书本下载版本信息缓存 打开情况
-(void) updateBook:(NSInteger)bookid OpenPage:(NSInteger)page  forUid:(NSInteger)uid;
-(void) updateBook:(NSInteger)bookid CacheEdition:(long long)edition  forUid:(NSInteger)uid;
-(NSInteger) getEditionForBook:(NSInteger)bookid  forUid:(NSInteger)uid;
-(NSArray *)getAllDownBooksIDstrForUid:(NSInteger)uid;
-(NSInteger) getLastOpenPageForBook:(NSInteger)bookid forUid:(NSInteger)uid;

//记录以及获取流式阅读器返回的JS数据
-(void) updateFlowBook:(NSInteger)bookid JSStr:(NSString*)jsStr ForUid:(NSInteger)uid;
-(NSString*) getFlowBookLastScrollStrWithBookId:(NSInteger)bookid ForUid:(NSInteger)uid;

//更新图片 通过version
- (void)updateImageView:(UIImageView *)imgv urlStr:(NSString *)uri edition:(NSString*)uri_edition;

//登陆信息保存
- (UserInfo*)getUserLoginInfo;
- (void)saveUserLoginInfo:(UserInfo*)dict;

//LocalPush
- (void)loaclRemindPush:(NSArray*)pushList update:(BOOL)update;

//设备登陆相关
//- (BOOL)isLastLoginFromDevice;
//- (void)setLastLoginFromDevice:(BOOL)yn;
- (BOOL)isLockedDeviceLogin;
- (void)setLockedDeviceLogin:(BOOL)yn;
//- (BOOL)isDeviceLockUser;
//- (BOOL)isLoginUser;
//无wifi下载
-(void)updateWifiStyle:(BOOL)wifiStyle;
-(NSString*)getWifiStyle;
//音效
-(void)updateVoiceStyle:(BOOL)voiceStyle;
-(NSString*)getVoiceStyle;
//疲劳模式
-(void)updateTiredStyle:(NSNumber*)tired;
-(NSNumber*)getTiredStyle;
-(void)updateTiredStyle_switchOff:(NSNumber*)tired;
-(NSNumber*)getTiredStyle_switchOff;
@end
